package cloud.tianai.ram.policy.common.handler;

import cloud.tianai.ram.policy.common.comparator.StatementComparator;
import cloud.tianai.ram.policy.common.model.dto.Match;
import cloud.tianai.ram.policy.common.model.dto.Statement;
import cloud.tianai.ram.policy.common.model.dto.Action;

import java.util.List;

/**
 * @Author: 天爱有情
 * @date 2022/3/7 14:45
 * @Description PermissionHandler
 */
public interface PermissionHandler extends StandardMatchHandler {

    /**
     * 匹配
     * 优先匹配拒绝策略
     *
     * @param statements          多个权限描述
     * @param action              行为描述
     * @param statementComparator 排序器
     * @return Match
     */
    Match handle(Action action, List<Statement> statements, StatementComparator statementComparator);

    /**
     * 匹配
     *
     * @param statements 多个权限描述
     * @param action     行为描述
     * @return Match
     */
    Match handle(Action action, List<Statement> statements);

    /**
     * 权限列表中是否包含是否允许某一个权限
     * @param statements statements
     * @param matched matched
     * @return boolean
     */
    boolean contains(List<Statement> statements, Statement matched);
}
